package sort;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.util.*;

import static java.lang.System.out;

/**
 * @Classname ListSort
 * @Author happytaohaha
 * @Date 2020/3/14
 * @Description ListSort
 */
public class ListSort {


    public static void main(String[] args) {
        String time ="2020/2/26 10:50:00";
        if(time.contains("-")){

        }
        Date date = new Date(time);
        if(date==null){
            System.out.println(123);
        }else{
            System.out.println(date.toString());
            try {
                System.out.println(dateTran(date,15));
            } catch (ParseException e) {
                e.printStackTrace();
            }
        }

    }

    //减去时间
    public static Date dateTran(Date date, Integer c) throws ParseException {
        SimpleDateFormat simFormat = new SimpleDateFormat("yyyy.MM.dd HH:mm:ss");
        Calendar cal1 = Calendar.getInstance();
        cal1.setTime(date);
        Integer i = 0 - c;
        cal1.add(Calendar.MINUTE, i);
        date = cal1.getTime();
        String s = simFormat.format(date);
        date = simFormat.parse(s);
        return date;
    }
}
